package com.example.money.test.HideToobar;

import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.View;

public class FooterBehaviorAppBar extends CoordinatorLayout.Behavior {

    public FooterBehaviorAppBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
/*
然会我们需要关心的类，
parent：是当前CoodinatorLayout
child：是我们设置Behavior的view
dependency:是我们关心的对象View
 */
    @Override
    public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
        return dependency instanceof AppBarLayout;//表示关心的对象是AppBarLayout
    }

    @Override
    public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
        float translationY = Math.abs(dependency.getY());
        child.setTranslationY(translationY);
        return true;
    }
}
